home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / processes / mp threaded sort / window.h < prev   
Encoding:
C/C++ Source or Header  |  2000-09-28  |  4.6 KB  |  157 lines

  1. /*
  2.     File:        Window.h
  3.  
  4.     Contains:    Definition of TWindow, a base class which provides a
  5.                 framework for building way-cool windows which even John
  6.                 Sullivan would be happy with. Floating windows and “smart
  7.                 zooming” algorithms are based on code samples provided by
  8.                 Dean Yu.
  9.  
  10.     Written by: Dave Falkenburg    
  11.  
  12.     Copyright:    Copyright © 1993-1999 by Apple Computer, Inc., All Rights Reserved.
  13.  
  14.                 You may incorporate this Apple sample source code into your program(s) without
  15.                 restriction. This Apple sample source code has been provided "AS IS" and the
  16.                 responsibility for its operation is yours. You are not permitted to redistribute
  17.                 this Apple sample source code as "Apple sample source code" after having made
  18.                 changes. If you're going to re-distribute the source, we require that you make
  19.                 it clear in the source that the code was descended from Apple sample source
  20.                 code, but that you've made changes.
  21.  
  22.     Change History (most recent first):
  23.                 7/27/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  24.                 11/12/94    DRF        Added AdjustMenusBeforeMenuSelection.
  25.                   11/8/94    DRF        Add some better menu handling methods.
  26.                   9/4/94    DRF        Added DrawJustTheGrowIcon.
  27.  
  28. */
  29.  
  30. #ifndef        _WINDOW_
  31. #define        _WINDOW_
  32.  
  33. #ifndef        __TYPES__
  34. #include    <Types.h>
  35. #endif
  36.  
  37. #ifndef        __WINDOWS__
  38. #include    <Windows.h>
  39. #endif
  40.  
  41. #ifndef        __EVENTS__
  42. #include    <Events.h>
  43. #endif
  44.  
  45. #ifndef        __DRAG__
  46. #include    <Drag.h>
  47. #endif
  48.  
  49. typedef    short    WindowTemplateID;
  50.  
  51.  
  52. class    TWindow
  53.     {
  54. public:
  55.     enum WindowType
  56.         {
  57.         kNormalWindow = 0,
  58.         kFloatingWindow,
  59.         kModalWindow
  60.         };
  61.  
  62.                         TWindow();
  63.     virtual                ~TWindow();
  64.  
  65.     //    Event routing methods
  66.  
  67.     virtual    Boolean        EventFilter(EventRecord * theEvent);    
  68.  
  69.     //    Methods you shouldn’t need to override, but might need to
  70.  
  71.     virtual void        CreateWindow(WindowType typeOfWindowToCreate = kNormalWindow);
  72.     virtual    void        Select(void);
  73.     virtual    void        Drag(Point startPoint);
  74.     virtual void        Nudge(short horizontalDistance, short verticalDistance);
  75.     virtual void        Grow(Point startPoint);
  76.     virtual void        Zoom(short zoomState);
  77.  
  78.     virtual    void        ShowHide(Boolean showFlag);
  79.  
  80.     //    Methods which MUST be overridden:
  81.  
  82.     virtual WindowPtr    MakeNewWindow(WindowPtr behindWindow)    = 0;
  83.     
  84.  
  85.     //    Methods which probably should be overridden
  86.  
  87.     virtual    void        AdjustCursor(EventRecord * anEvent);
  88.     virtual void        Idle(EventRecord * anEvent);
  89.     virtual void        Activate(Boolean activating);
  90.     virtual void        Draw(void);
  91.     virtual void        Click(EventRecord * anEvent);
  92.     virtual    void        KeyDown(EventRecord * anEvent);
  93.  
  94.     virtual void        GetPerfectWindowSize(Rect * perfectSize);
  95.     virtual    void        GetWindowSizeLimits(Rect * limits);
  96.     virtual void        AdjustForNewWindowSize(Rect * oldRect,Rect * newRect);
  97.  
  98.  
  99.     //    Window property accessor methods…
  100.     //        …watch for new ones when we add scripting support    
  101.     
  102.     virtual    Boolean        IsVisible(void);
  103.     
  104.     virtual    Boolean        CanClose(void);        
  105.     virtual    Boolean        Close(void);
  106.     virtual    Boolean        DeleteAfterClose(void);
  107.     
  108.     //    Methods for handling menus & menu commands
  109.     
  110.     virtual    void        AdjustMenusBeforeMenuSelection(void);
  111.     virtual void        DoMenuSelection(short menu, short item);
  112.     virtual void        DoMenuCommand(unsigned long menuCommand);
  113.  
  114.     //    Methods for use with the Drag Manager
  115.     
  116.     virtual    OSErr        HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag);
  117.  
  118.     virtual    OSErr        DragEnterWindow(DragReference theDrag);
  119.     virtual    OSErr        DragInWindow(DragReference theDrag);
  120.     virtual    OSErr        DragLeaveWindow(DragReference theDrag);
  121.  
  122.     virtual    OSErr        HandleDrop(DragReference theDragRef);
  123.  
  124.  
  125. protected:
  126.     WindowPtr            fWindow;
  127.     WindowType            fWindowType;
  128.  
  129.     Boolean                fIsVisible;
  130.     };
  131.  
  132.  
  133. //    Utility Functions:
  134.  
  135. //    Don’t you just wish you didn’t have to do this?
  136. pascal WindowPtr    GetNewColorOrBlackAndWhiteWindow(short windowID, void *wStorage, WindowPtr behind);
  137. pascal WindowPtr    NewColorOrBlackAndWhiteWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon);
  138.  
  139. void                DrawJustTheGrowIcon(WindowPtr theWindow);
  140.  
  141. TWindow *            GetWindowObject(WindowPtr aWindow);
  142.  
  143. WindowPtr            FrontModalWindow(void);
  144. WindowPtr            LastModalWindow(void);
  145. WindowPtr            FrontFloatingWindow(void);
  146. WindowPtr            LastFloatingWindow(void);
  147. WindowPtr            MyFrontNonFloatingWindow(void);
  148.  
  149. void                HiliteAndActivateWindow(WindowPtr aWindow,Boolean active);
  150. void                SuspendResumeWindows(Boolean resuming);
  151. void                HiliteWindowsForModalDialog(Boolean hiliting);
  152.  
  153. pascal OSErr        CallWindowDragTrackingHandler(DragTrackingMessage message,WindowPtr theWindow,void *handlerRefCon,DragReference theDragRef);
  154. pascal OSErr        CallWindowDragReceiveHandler(WindowPtr theWindow, void *handlerRefCon,DragReference theDragRef);
  155.  
  156. #endif
  157.